# -*- coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()

import os
import tornado.web
import tornado.ioloop
from tornado import httpserver

from views import main_handler


PORT = '8200'

settings = {
    "xsrf_cookies": False,
    "cookie_secret": "HeavyMetalWillNeverDie",
    "static_path": os.path.join(os.path.dirname(__file__), "static"),
    "template_path": os.path.join(os.path.dirname(__file__), "templates"),
    "debug": True,
}

application = tornado.web.Application(
    handlers=[(r"/", main_handler.IndexHandler),
              (r"/commits", main_handler.CommitHandler),
              (r"/report", main_handler.ReportHandler),
              (r"/report/show", main_handler.ReportShowHandler),
              (r"/report/progress", main_handler.ProgressHandler),
              (r"/config/desc", main_handler.DescHandler)
              ], **settings
)


if __name__ == '__main__':
    http_server = httpserver.HTTPServer(application)
    http_server.listen(PORT)
    print "http://192.168.11.112:8200/"
    tornado.ioloop.IOLoop.instance().start()
